package firing;

import game.Bullet;
import game.Enemy;
import game.Player;

import java.util.List;

/** Node that will make decisions based on angle player is traveling in */
public class PlayerUpDownBranch extends AbstractBinaryNode {

    /**
     * 
     */
    private static final long serialVersionUID = -3718309402889893738L;

    @Override
    public void calculate(List<Bullet> bullets, double angle, Enemy shooter, Player player) {
	if (player.getAngle() < Math.PI && left != null) {
	    left.calculate(bullets, angle, shooter, player);
	} else if (right != null) {
	    right.calculate(bullets, angle, shooter, player);
	}
    }

    @Override
    public void randomizeNode() {
	//there is no randomness to be had here
    }
    
    public String toString() {
	return "Player LeftRight Branch";
    }

    @Override
    public Node duplicate() {
	PlayerUpDownBranch result = new PlayerUpDownBranch();
	if (left != null) {
	    result.left = left.duplicate();
	}
	if (right != null) {
	    result.right = right.duplicate();
	}
	return result;
    }

}
